package com.server;

import com.grpc.FutureProto;
import com.grpc.FutureServiceGrpc;
import io.grpc.stub.StreamObserver;

import java.util.concurrent.TimeUnit;


public class FutureServiceImpl extends FutureServiceGrpc.FutureServiceImplBase {

    public void future(FutureProto.FutureRequest request, StreamObserver<FutureProto.FutureResponse> responseObserver) {
        String name = request.getName();
        FutureProto.FutureResponse.Builder builder = FutureProto.FutureResponse.newBuilder();
        FutureProto.FutureResponse helloResponse = builder.setResult(name + " 的响应数据 ~").build();
        try {TimeUnit.SECONDS.sleep(3);}catch (Exception e){e.printStackTrace();}
        responseObserver.onNext(helloResponse);
        responseObserver.onCompleted();
    }
}
